<?php

namespace App\Http\Requests\Home;

use Illuminate\Foundation\Http\FormRequest;

class UserAccount extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'nickname'  => 'required|min:6|max:20|alpha_dash',
            'email'     => 'required|email',
            'phone'     =>[
                'required',
                'regex:/^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$/',
            ],
            'address'   => 'required'
            'sex'       => 'required'
        ];
    }

    public function messages()
    {
         return [
            'nickname.required'  => '请输入昵称名',
            'nickname.min'       =>  '昵称最少6个字符',
            'nickname.max'       =>  '昵称最多20个字符',
            'nickname.alpha_dash'=> '请用字母、数字、破折号（ - ）以及下划线（ _ ）',

            'email.required' => '请输入邮箱',
            'email.email'    => '邮箱不合法',

            'phone.required'   => '请输入手机号码',
            'phone.regex'      => '手机号不合法',

            'sex.required'     => '性别不能为空',

            'address.required' => '地址不能为空',
        ];
    }
}
